package com.leetcode.LC;

import java.util.ArrayList;

public class LC500 {
    public String[] findWords(String[] words) {
        ArrayList<String> list = new ArrayList<>();
        String s1 = "qwertyuiopQWERTYUIOP";
        String s2 = "asdfghjklASDFGHJKL";
        String s3 = "zxcvbnmZXCVBNM";

        for (String word : words) {
            int n1 = 0, n2 = 0, n3 = 0, length = word.length();
            for (int i = 0; i < length; i++) {
                if (s1.contains(word.charAt(i) + "")) n1++;
                else if (s2.contains(word.charAt(i) + "")) n2++;
                else n3++;
            }
            if(n1 == length || n2 == length || n3 == length) list.add(word);
        }

        return list.toArray(new String[list.size()]);
    }

    public static void main(String[] args) {
        for (String word : new LC500().findWords(new String[]{"Hello", "Alaska", "Dad", "Peace"})) {
            System.out.print(word+",");
        }
    }
}
